/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * InicioFrame.java
 *
 * Created on Oct 23, 2011, 12:20:47 PM
 */
package com.appredes.view;

import com.appredes.controller.myMain;

/**
 *
 * @author Cloud Strife
 */
public class InicioFrame extends javax.swing.JFrame {

    /** Creates new form InicioFrame */
    public InicioFrame() {
        initComponents();
        
        setLocationRelativeTo(null);
        
        pnlDatos.setVisible(false);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        txtDirIP = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        btnValidar = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        pnlDatos = new javax.swing.JPanel();
        lblClase = new javax.swing.JLabel();
        lblRangoDir = new javax.swing.JLabel();
        lblNumRedes = new javax.swing.JLabel();
        lblNumHost = new javax.swing.JLabel();
        lblMascara = new javax.swing.JLabel();
        lblClase2 = new javax.swing.JLabel();
        lblRangoDir2 = new javax.swing.JLabel();
        lblNumRedes2 = new javax.swing.JLabel();
        lblNumHost2 = new javax.swing.JLabel();
        lblMascara2 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(aplicativoredes.AplicativoRedesApp.class).getContext().getResourceMap(InicioFrame.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setBackground(resourceMap.getColor("Form.background")); // NOI18N
        setName("Form"); // NOI18N
        setResizable(false);

        jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(0));
        jPanel1.setName("jPanel1"); // NOI18N

        txtDirIP.setFont(resourceMap.getFont("txtDirIP.font")); // NOI18N
        txtDirIP.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtDirIP.setText(resourceMap.getString("txtDirIP.text")); // NOI18N
        txtDirIP.setToolTipText(resourceMap.getString("txtDirIP.toolTipText")); // NOI18N
        txtDirIP.setName("txtDirIP"); // NOI18N

        jLabel1.setFont(resourceMap.getFont("lblMascara.font")); // NOI18N
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        btnValidar.setFont(resourceMap.getFont("btnValidar.font")); // NOI18N
        btnValidar.setText(resourceMap.getString("btnValidar.text")); // NOI18N
        btnValidar.setName("btnValidar"); // NOI18N
        btnValidar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnValidarActionPerformed(evt);
            }
        });

        jButton1.setFont(resourceMap.getFont("jButton1.font")); // NOI18N
        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(240, 240, 240)
                        .addComponent(btnValidar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 144, Short.MAX_VALUE)
                        .addComponent(jButton1))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(173, 173, 173)
                        .addComponent(txtDirIP, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(207, 207, 207)
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtDirIP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnValidar)
                    .addComponent(jButton1))
                .addContainerGap(21, Short.MAX_VALUE))
        );

        pnlDatos.setBorder(javax.swing.BorderFactory.createBevelBorder(0));
        pnlDatos.setName("pnlDatos"); // NOI18N

        lblClase.setFont(resourceMap.getFont("lblClase.font")); // NOI18N
        lblClase.setText(resourceMap.getString("lblClase.text")); // NOI18N
        lblClase.setName("lblClase"); // NOI18N

        lblRangoDir.setFont(resourceMap.getFont("lblMascara.font")); // NOI18N
        lblRangoDir.setText(resourceMap.getString("lblRangoDir.text")); // NOI18N
        lblRangoDir.setName("lblRangoDir"); // NOI18N

        lblNumRedes.setFont(resourceMap.getFont("lblMascara.font")); // NOI18N
        lblNumRedes.setText(resourceMap.getString("lblNumRedes.text")); // NOI18N
        lblNumRedes.setName("lblNumRedes"); // NOI18N

        lblNumHost.setFont(resourceMap.getFont("lblMascara.font")); // NOI18N
        lblNumHost.setText(resourceMap.getString("lblNumHost.text")); // NOI18N
        lblNumHost.setName("lblNumHost"); // NOI18N

        lblMascara.setFont(resourceMap.getFont("lblMascara.font")); // NOI18N
        lblMascara.setText(resourceMap.getString("lblMascara.text")); // NOI18N
        lblMascara.setName("lblMascara"); // NOI18N

        lblClase2.setFont(resourceMap.getFont("lblRangoDir2.font")); // NOI18N
        lblClase2.setText(resourceMap.getString("lblClase2.text")); // NOI18N
        lblClase2.setName("lblClase2"); // NOI18N

        lblRangoDir2.setFont(resourceMap.getFont("lblRangoDir2.font")); // NOI18N
        lblRangoDir2.setText(resourceMap.getString("lblRangoDir2.text")); // NOI18N
        lblRangoDir2.setName("lblRangoDir2"); // NOI18N

        lblNumRedes2.setFont(resourceMap.getFont("lblRangoDir2.font")); // NOI18N
        lblNumRedes2.setText(resourceMap.getString("lblNumRedes2.text")); // NOI18N
        lblNumRedes2.setName("lblNumRedes2"); // NOI18N

        lblNumHost2.setFont(resourceMap.getFont("lblRangoDir2.font")); // NOI18N
        lblNumHost2.setText(resourceMap.getString("lblNumHost2.text")); // NOI18N
        lblNumHost2.setName("lblNumHost2"); // NOI18N

        lblMascara2.setFont(resourceMap.getFont("lblRangoDir2.font")); // NOI18N
        lblMascara2.setText(resourceMap.getString("lblMascara2.text")); // NOI18N
        lblMascara2.setName("lblMascara2"); // NOI18N

        javax.swing.GroupLayout pnlDatosLayout = new javax.swing.GroupLayout(pnlDatos);
        pnlDatos.setLayout(pnlDatosLayout);
        pnlDatosLayout.setHorizontalGroup(
            pnlDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDatosLayout.createSequentialGroup()
                .addGap(77, 77, 77)
                .addGroup(pnlDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblClase, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblRangoDir)
                    .addComponent(lblNumRedes)
                    .addComponent(lblNumHost)
                    .addComponent(lblMascara))
                .addGap(71, 71, 71)
                .addGroup(pnlDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblClase2, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblRangoDir2, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(pnlDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(lblMascara2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(lblNumHost2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(lblNumRedes2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pnlDatosLayout.setVerticalGroup(
            pnlDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDatosLayout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(pnlDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblClase)
                    .addComponent(lblClase2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblRangoDir)
                    .addComponent(lblRangoDir2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblNumRedes)
                    .addComponent(lblNumRedes2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblNumHost)
                    .addComponent(lblNumHost2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblMascara)
                    .addComponent(lblMascara2))
                .addContainerGap(26, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(pnlDatos, javax.swing.GroupLayout.Alignment.LEADING, 0, 558, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
                .addComponent(pnlDatos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void btnValidarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnValidarActionPerformed

    String ip = txtDirIP.getText(); 
    if(myMain.contro.crearIP(ip)){

        lblClase2.setText(myMain.contro.getTipoClase());
        lblRangoDir2.setText(myMain.contro.getRangoClases());
        lblNumRedes2.setText(""+myMain.contro.getNumeroOfRedes());
        lblNumHost2.setText(""+myMain.contro.getNumeroOfHosts());
        lblMascara2.setText(myMain.contro.getMascaraPredeterminada());

        pnlDatos.setVisible(true);
    }
}//GEN-LAST:event_btnValidarActionPerformed

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    
    new SubNetingFrame().setVisible(true);
    
}//GEN-LAST:event_jButton1ActionPerformed

    /**
     * @param args the command line arguments
     */
//    public static void main(String args[]) {
//        /* Set the Nimbus look and feel */
//        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
//        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
//         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
//         */
//        try {
//            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
//                if ("Nimbus".equals(info.getName())) {
//                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
//                    break;
//                }
//            }
//        } catch (ClassNotFoundException ex) {
//            java.util.logging.Logger.getLogger(InicioFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (InstantiationException ex) {
//            java.util.logging.Logger.getLogger(InicioFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (IllegalAccessException ex) {
//            java.util.logging.Logger.getLogger(InicioFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
//            java.util.logging.Logger.getLogger(InicioFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        }
//        //</editor-fold>
//
//        /* Create and display the form */
//        java.awt.EventQueue.invokeLater(new Runnable() {
//
//            public void run() {
//                new InicioFrame().setVisible(true);
//            }
//        });
//    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnValidar;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel lblClase;
    private javax.swing.JLabel lblClase2;
    private javax.swing.JLabel lblMascara;
    private javax.swing.JLabel lblMascara2;
    private javax.swing.JLabel lblNumHost;
    private javax.swing.JLabel lblNumHost2;
    private javax.swing.JLabel lblNumRedes;
    private javax.swing.JLabel lblNumRedes2;
    private javax.swing.JLabel lblRangoDir;
    private javax.swing.JLabel lblRangoDir2;
    private javax.swing.JPanel pnlDatos;
    private javax.swing.JTextField txtDirIP;
    // End of variables declaration//GEN-END:variables
}
